﻿<Window x:Class="SqlServerMaintenanceSolution.Views.Login"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
        Title="Connect to Server" Width="400" MaxWidth="400"
        xmlns:uc="clr-namespace:SqlServerMaintenanceSolution.UserControls"
        WindowStartupLocation="CenterScreen"  ResizeMode="NoResize" 
        Background="#FFEEEAEA"
        Icon="..\Images\TitleIcon.png" 
        SizeToContent="Height">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
        <Style TargetType="StackPanel" x:Key="SeparatorStackPanel">
            <Setter Property="Orientation" Value="Horizontal"/>
            <Setter Property="Margin" Value="0,5,0,0"/>
        </Style>
        <Style TargetType="xctk:IntegerUpDown">
            <Setter Property="Width" Value="55"/>
            <Setter Property="Height" Value="24"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
        </Style>
    </Window.Resources>

    <DockPanel Margin="0,0,0,0" LastChildFill="True">
        <uc:Header DockPanel.Dock="Top"/>
        <Border DockPanel.Dock="Bottom" 
                BorderThickness="0,1,0,0" 
                BorderBrush="Black" 
                Margin="5,0,5,5" 
                Padding="0,5,5,0">
            <StackPanel  Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Content="Connect"  Command="{Binding ConnectClickCommand}"  />
                <Button Content="Cancel" Command="{Binding ExitCommand}" HorizontalAlignment="Left"  />
                <Button Content="Help"  Command="{Binding HelpClickCommand}" HorizontalAlignment="Left" />
                <Button Content="Options>>" Command="{Binding OptionsClickCommand}" HorizontalAlignment="Left" />
            </StackPanel>
        </Border>

        <Grid Margin="5, 25, 5, 25">
            <Grid.Resources>
                <Style TargetType="Label">
                    <Setter Property="HorizontalContentAlignment" Value="Right"/>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="Margin" Value="5, 0, 20, 0"/>
                </Style>
                <Style TargetType="FrameworkElement" x:Key="InputElement">
                    <Setter Property="Width" Value="185"/>
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                    <Setter Property="VerticalAlignment" Value="Center"/>
                </Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40*"/>
                <ColumnDefinition Width="60*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>

            <!--Server-->
            <Label Content="Server name:" 
                   Grid.Row="0" />
            <ComboBox x:Name="cbSqlServerInstances" 
                      Grid.Column="1"
                      ItemsSource="{Binding SqlServerInstances}" 
                      SelectedItem="{Binding SqlServerInstance}"  
                      DisplayMemberPath="CompleteName" 
                      Style="{StaticResource InputElement}"/>
            <!--Authentication Type-->
            <Label Content="Authentication:"  
                   Grid.Row="1" VerticalAlignment="Center" />
            <ComboBox ItemsSource="{Binding SqlServerAuthentications}" 
                      Grid.Row="1" Grid.Column="1"
                      SelectedItem="{Binding SqlServerAuthentication}" 
                      DisplayMemberPath="DisplayName"
                      Style="{StaticResource InputElement}"/>
            <!--User Name-->
            <Label Content="User name:" 
                   Grid.Row="2"  />
            <TextBox Text="{Binding Path=UserID, UpdateSourceTrigger=PropertyChanged}" 
                     Grid.Row="2" Grid.Column="1"
                     IsEnabled="{Binding IntegratedSecurity}" 
                     Style="{StaticResource InputElement}"
                     TextWrapping="Wrap"/>
            <!--Password-->
            <Label Content="Password:" 
                   Grid.Row="3"/>
            <TextBox Text="{Binding Path=Password, UpdateSourceTrigger=PropertyChanged}" 
                     Grid.Row="3" Grid.Column="1"
                     IsEnabled="{Binding IntegratedSecurity}" 
                     Style="{StaticResource InputElement}"
                     TextWrapping="Wrap"/>
            <!--Options Grid-->
            <Grid Grid.Row="4" Grid.ColumnSpan="2" 
                  Visibility="{Binding OptionsVisible, Converter={StaticResource booleanToVisibilityConverter }}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="40*"/>
                    <ColumnDefinition Width="60*"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <!--Network options-->
                <StackPanel Style="{StaticResource SeparatorStackPanel}" Grid.ColumnSpan="2">
                    <TextBlock Text="Network"  Margin="10,0,15,0" HorizontalAlignment="Right" />
                    <Separator Width="270" />
                </StackPanel>

                <Label Content="Network Protocol:" 
                       Grid.Row="1"/>
                <ComboBox x:Name="cbNetworkProtocols" 
                          Grid.Row="1" Grid.Column="1"
                          ItemsSource="{Binding NetworkProtocols}" 
                          SelectedItem="{Binding NetworkProtocol}"
                          DisplayMemberPath="Protocol" 
                          Style="{StaticResource InputElement}" />

                <Label Content="Network packet size:"
                       Grid.Row="2"/>
                <StackPanel Grid.Row="2" Grid.Column="1"
                            Orientation="Horizontal">

                    <xctk:IntegerUpDown Name="NetworkPacketSize" 
                                    Value="4096" />
                    <TextBlock VerticalAlignment="Center"
                               Margin="5,0,0,0"
                               Text="bytes" />
                </StackPanel>


                <!--ConnectionOptions-->
                <StackPanel Style="{StaticResource SeparatorStackPanel}"
                            Grid.ColumnSpan="2"
                            Grid.Row="3">
                    <TextBlock Text="Connection"  Margin="10,0,15,0" />
                    <Separator Width="255" />
                </StackPanel>

                <Label Content="Connection Time-out:" 
                       Grid.Row="4"/>
                <StackPanel Grid.Row="4" Grid.Column="1"
                            Orientation="Horizontal">
                    <xctk:IntegerUpDown Name="ConnectionTimeOut" 
                                        Value="15"/>
                    <TextBlock VerticalAlignment="Center"
                               Margin="5,0,0,0"
                               Text="seconds" />
                </StackPanel>

                <Label Content="Execution Time-out:" 
                       Grid.Row="5"/>
                <StackPanel Grid.Row="5" Grid.Column="1"
                            Orientation="Horizontal">
                    <xctk:IntegerUpDown Name="ExecutionTimeOut" 
                                        Value="0"  />
                    <TextBlock VerticalAlignment="Center"
                               Margin="5,0,0,0"
                               Text="seconds" />
                </StackPanel>

                <CheckBox Content="Encrypt Connection" 
                          Grid.Row="6" Grid.ColumnSpan="2"
                          Margin="25,10,0,0" />
            </Grid>
        </Grid>
    </DockPanel>
</Window>
